//
//  MTCheckoutResultController.swift
//  MT
//
//  Created by 陈悦 on 2020/5/7.
//  Copyright © 2020 张强. All rights reserved.
//


import UIKit
import MTCategory
import YPNavigationBarTransition

class MTCheckoutResultController: BaseViewController {
    //关闭按钮
    lazy var closeImage: UIImageView = {
        let imgView = UIImageView()
        imgView.image = UIImage(named: "close-black")
        imgView.contentMode = .center
        imgView.clipsToBounds = true
        imgView.isUserInteractionEnabled = true
        let tap = UITapGestureRecognizer(target: self, action: #selector(checkoutResultViewController(didTapCloseImage:)))
        imgView.addGestureRecognizer(tap)
        return imgView
        
    }()
    
    //状态icon
    lazy var statusImage: UIImageView = {
        let imgView = UIImageView()
        imgView.image = UIImage(named: "success")
        imgView.contentMode = .scaleAspectFill
        return imgView
        
    }()
    
    //状态描述
    lazy var statusDesc: UILabel = {
        let label = UILabel()
        label.text = "提现申请已提交"
        label.textColor = UIColor(hex:0x2f2f2f)
        label.font = PingFangSCSemiboldFont(24)
        label.textAlignment = .center
        return label
        
    }()
    
    //状态描述
    lazy var subStatusDesc: UILabel = {
        let label = UILabel()
        label.text = "请注意查看提现金额到账信息"
        label.textColor = UIColor(hex:0x9b9b9b)
        label.font = PingFangSCRegularFont(12)
        label.textAlignment = .center
        return label
        
    }()
    
    //回首页按钮
    lazy var goHomeButton: UIButton = {
        let btn = UIButton()
        btn.setTitle("返回首页>>", for: .normal)
        btn.setTitleColor(UIColor(hex:0x2f2f2f), for: .normal)
        btn.titleLabel?.font = PingFangSCRegularFont(16)
        btn.adjustsImageWhenHighlighted = false
        btn.addTarget(self, action: #selector(checkoutResultViewController(didTapHomeImage:)), for: .touchUpInside)
        return btn
    }()

    
}

// MARK: ------------------------------------ Overrides ----------------------------------------
extension MTCheckoutResultController {
    override func viewDidLoad() {
        super.viewDidLoad()
        initializeUI()
    }
    
    override func yp_navigtionBarConfiguration() -> YPNavigationBarConfigurations {
        .backgroundStyleTransparent
    }
    
    override func yp_navigationBarTintColor() -> UIColor! {
        UIColor(hex: 0xFFFFFF)
    }

    override func yp_navigationBackgroundColor() -> UIColor! {
        .clear
    }
    
    override var preferredStatusBarStyle: UIStatusBarStyle {
        return .default
    }

    override func yp_navigationBackgroundImage(withIdentifier identifier: AutoreleasingUnsafeMutablePointer<NSString?>!) -> UIImage! {
        return nil
    }
}

// MARK: ---------------------------------------- 初始化 --------------------------------------------
extension MTCheckoutResultController {
    
    private func initializeUI() {
        view.backgroundColor = UIColor(hex: 0xf6f6f6)
        view.addSubview(closeImage)
        view.addSubview(statusImage)
        view.addSubview(statusDesc)
        view.addSubview(subStatusDesc)
        view.addSubview(goHomeButton)
        
        closeImage.snp.makeConstraints { (make) in
            make.top.equalTo(view).offset(StatusBarHeight+15)
            make.left.equalTo(view).offset(5)
            make.width.height.equalTo(44)
        }
        
        statusImage.snp.makeConstraints { (make) in
            make.centerX.equalTo(view)
            make.centerY.equalTo(view).offset(-140)
            make.width.height.equalTo(66)
        }
        
        statusDesc.snp.makeConstraints { (make) in
            make.centerX.equalTo(view)
            make.top.equalTo(statusImage.snp.bottom).offset(15)
        }
        
        subStatusDesc.snp.makeConstraints { (make) in
            make.centerX.equalTo(view)
            make.top.equalTo(statusDesc.snp.bottom).offset(20)
        }
        
        goHomeButton.snp.makeConstraints { (make) in
            make.centerX.equalTo(view)
            make.top.equalTo(subStatusDesc.snp.bottom).offset(90)
        }
    }
        
}

// MARK: ---------------------------------------- 事件方法 -------------------------------------------
@objc
extension MTCheckoutResultController {

    private func checkoutResultViewController(didTapCloseImage sender: UIButton) {
        self.navigationController?.popToRootViewController(animated: true)
    }

    private func checkoutResultViewController(didTapHomeImage sender: UIButton) {
        self.navigationController?.popToRootViewController(animated: true)
    }
}
